package com.hns.tool.pub;

import java.util.UUID;

/**
 * 数据工具类
 * @author:Fisher
 * @email:zhuangcaijin@126.com
 * @version Revision 2.0.0
 */
public class DataUtil {
    
	/**
	 * 生成32位ID
	 * @return 生成的ID字符串
	 * @author:Fisher
     * @email:zhuangcaijin@126.com
	 */
    public static String sequenceID() {
        return UUID.randomUUID().toString().replace("-", "");
    }
    
    /**
     * 流水号生成工具
     * @param currentId 当前节点id
     * @param levelDigit 每一级的位数
     * @param lowerCnt 下级节点数
     * @return 流水号字符串
     * @author:Fisher
     * @email:zhuangcaijin@126.com
     */
    public static String buildId(String currentId, int levelDigit, int lowerCnt) {
        String id = "0000"+String.valueOf(lowerCnt);
        id = id.substring(id.length()-levelDigit);
        id = currentId + id;
        return id;
    }
    
    static class Tester {
        public static void main(String[] args) {
            System.out.println("ID buildId " + DataUtil.buildId("800002", 3, 1));
        }
    }
}
